package com.qumap.item;


import com.qumap.item.content.ObjectOnMapShort;

/**
 * Created by IntelliJ IDEA.
 * User: Admin
 * Date: 10.05.11
 * Time: 18:16
 * To change this template use File | Settings | File Templates.
 */
public class ItemOnMap {

	private static int item_sequence;

	protected int id = item_sequence++;

	protected final ItemInfo info;
    private ObjectOnMapShort content;

    private boolean hasChanges;
    private boolean content_fully_loaded;

	public ItemOnMap(ItemInfo info) {
		this.info = info;
	}

	public ItemInfo getItemInfo() {
		return info;
	}

	public double getLongtitude() {
		return content.getLongtitude();
	}

	public void setLongtitude(double longtitude) {
		content.setLongtitude(longtitude);
        setHashChanges(true);
	}

	public double getLattitude() {
		return content.getLattitude();
	}

	public void setLattitude(double lattitude) {
		content.setLattitude(lattitude);
        setHashChanges(true);
	}

	public int getId() {
		return id;
	}

    public void setHashChanges(boolean hashChanges) {
        this.hasChanges = hashChanges;
    }

    public boolean hasChanges() {
        return hasChanges;
    }

    public boolean isPersisted() {
        return content.getId() != ObjectOnMapShort.UNSET;
    }

    public void setContent(ObjectOnMapShort content) {
        this.content = content;
    }

    public ObjectOnMapShort getContent() {
        return content;
    }

    public boolean isFullyLoad() {
        return content_fully_loaded;
    }

    public void setFullyLoad() {
        content_fully_loaded = true;
    }



	@Override
	public boolean equals(Object o) {
		if (this == o) return true;
		if (o == null || getClass() != o.getClass()) return false;

		ItemOnMap item = (ItemOnMap) o;

		if (id != item.id) return false;

		return true;
	}

	@Override
	public int hashCode() {
		return id;
	}
}
